package com.ruoyi.find.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.find.domain.SysSubway;
import com.ruoyi.find.service.ISysSubwayService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 地铁线路Controller
 * 
 * @author LiuWeiChen
 * @date 2025-09-12
 */
@RestController
@RequestMapping("/subway")
public class SysSubwayController extends BaseController
{
    @Autowired
    private ISysSubwayService sysSubwayService;

    /**
     * 查询地铁线路列表
     */
    @RequiresPermissions("find:subway:list")
    @GetMapping("/list")
    public TableDataInfo list(SysSubway sysSubway)
    {
        startPage();
        List<SysSubway> list = sysSubwayService.selectSysSubwayList(sysSubway);
        return getDataTable(list);
    }

    /**
     * 导出地铁线路列表
     */
    @RequiresPermissions("find:subway:export")
    @Log(title = "地铁线路", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysSubway sysSubway)
    {
        List<SysSubway> list = sysSubwayService.selectSysSubwayList(sysSubway);
        ExcelUtil<SysSubway> util = new ExcelUtil<SysSubway>(SysSubway.class);
        util.exportExcel(response, list, "地铁线路数据");
    }

    /**
     * 获取地铁线路详细信息
     */
    @RequiresPermissions("find:subway:query")
    @GetMapping(value = "/{subwayId}")
    public AjaxResult getInfo(@PathVariable("subwayId") Long subwayId)
    {
        return success(sysSubwayService.selectSysSubwayBySubwayId(subwayId));
    }

    /**
     * 新增地铁线路
     */
    @RequiresPermissions("find:subway:add")
    @Log(title = "地铁线路", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysSubway sysSubway)
    {
        return toAjax(sysSubwayService.insertSysSubway(sysSubway));
    }

    /**
     * 修改地铁线路
     */
    @RequiresPermissions("find:subway:edit")
    @Log(title = "地铁线路", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysSubway sysSubway)
    {
        return toAjax(sysSubwayService.updateSysSubway(sysSubway));
    }

    /**
     * 删除地铁线路
     */
    @RequiresPermissions("find:subway:remove")
    @Log(title = "地铁线路", businessType = BusinessType.DELETE)
	@DeleteMapping("/{subwayIds}")
    public AjaxResult remove(@PathVariable Long[] subwayIds)
    {
        return toAjax(sysSubwayService.deleteSysSubwayBySubwayIds(subwayIds));
    }
    @RequiresPermissions("find:subway:getRegion")
    @GetMapping("/getRegion")
    public AjaxResult getRegion()
    {
        return sysSubwayService.getRegion();
    }
}
